﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class Carousel_轮播_DAL
    {
        /// <summary>
        /// 首页轮播
        /// </summary>
        /// <returns></returns>
        public List<Carousel_轮播_> ShowCarouse()
        {
            using (SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=JingRui;Integrated Security=True"))
            {
                string sql = "select * from [Carousel(轮播)]";
                SqlCommand com = new SqlCommand(sql, con);
                SqlDataAdapter sd = new SqlDataAdapter(com);
                DataTable dt = new DataTable();
                sd.Fill(dt);
                List<Carousel_轮播_> list = new List<Carousel_轮播_>();
                foreach (DataRow item in dt.Rows)
                {
                    Carousel_轮播_ a = new Carousel_轮播_();
                    a.Carouselid = Convert.ToInt32(item["Carouselid"]);
                    a.Carouselimg = item["Carouselimg"].ToString();
                    a.Carouselmonth = item["Carouselmonth"].ToString();                  
                    list.Add(a);
                }
                return list;

            }
        }
    }
}
